/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.db;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "account_invest")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AccountInvest.findAll", query = "SELECT a FROM AccountInvest a"),
    @NamedQuery(name = "AccountInvest.findById", query = "SELECT a FROM AccountInvest a WHERE a.id = :id"),
    @NamedQuery(name = "AccountInvest.findByInvestID", query = "SELECT a FROM AccountInvest a WHERE a.investID = :investID"),
    @NamedQuery(name = "AccountInvest.findByRegionID", query = "SELECT a FROM AccountInvest a WHERE a.regionID = :regionID"),
    @NamedQuery(name = "AccountInvest.findByInvestName", query = "SELECT a FROM AccountInvest a WHERE a.investName = :investName"),
    @NamedQuery(name = "AccountInvest.findByBrokerID", query = "SELECT a FROM AccountInvest a WHERE a.brokerID = :brokerID"),
    @NamedQuery(name = "AccountInvest.findByPwd", query = "SELECT a FROM AccountInvest a WHERE a.pwd = :pwd"),
    @NamedQuery(name = "AccountInvest.findByType", query = "SELECT a FROM AccountInvest a WHERE a.type = :type"),
    @NamedQuery(name = "AccountInvest.findByOwnUserID", query = "SELECT a FROM AccountInvest a WHERE a.ownUserID = :ownUserID"),
    @NamedQuery(name = "AccountInvest.findByAlterUserID", query = "SELECT a FROM AccountInvest a WHERE a.alterUserID = :alterUserID"),
    @NamedQuery(name = "AccountInvest.findByCreateTime", query = "SELECT a FROM AccountInvest a WHERE a.createTime = :createTime"),
    @NamedQuery(name = "AccountInvest.findByTimeStamp", query = "SELECT a FROM AccountInvest a WHERE a.timeStamp = :timeStamp")})
public class AccountInvest implements Serializable {
	public static byte[] EnCode(AccountInvest msg) throws IOException {
		Codec<AccountInvest> Lcode = ProtobufProxy.create(AccountInvest.class);
		return Lcode.encode(msg);
	}
	public static AccountInvest DeCode(byte[] data) throws IOException {
	Codec<AccountInvest> Lcode = ProtobufProxy.create(AccountInvest.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    @Protobuf
	private Integer id;
    @Basic(optional = false)
    @Column(name = "InvestID")
    @Protobuf
	private String investID;
    @Basic(optional = false)
    @Column(name = "RegionID")
    @Protobuf
	private String regionID;
    @Column(name = "InvestName")
    private String investName;
	@Protobuf
	private byte[] investNameBit;
    @Column(name = "BrokerID")
    @Protobuf
	private String brokerID;
    @Basic(optional = false)
    @Column(name = "Pwd")
    @Protobuf
	private String pwd;
    @Basic(optional = false)
    @Column(name = "Type")
    @Protobuf
	private String type;
    @Basic(optional = false)
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public AccountInvest() {
    }

    public AccountInvest(Integer id) {
        this.id = id;
    }

    public AccountInvest(Integer id, String investID, String regionID, String pwd, String type, String ownUserID) {
        this.id = id;
        this.investID = investID;
        this.regionID = regionID;
        this.pwd = pwd;
        this.type = type;
        this.ownUserID = ownUserID;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getInvestID() {
        return investID;
    }

    public void setInvestID(String investID) {
        this.investID = investID;
    }

    public String getRegionID() {
        return regionID;
    }

    public void setRegionID(String regionID) {
        this.regionID = regionID;
    }

    public String getInvestName() {
        return investName;
    }

    public void setInvestName(String investName) {
        this.investName = investName;
        this.setInvestNameBit(CodeTool.StringToBit(investName));
    }

    public String getBrokerID() {
        return brokerID;
    }

    public void setBrokerID(String brokerID) {
        this.brokerID = brokerID;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AccountInvest)) {
            return false;
        }
        AccountInvest other = (AccountInvest) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.db.AccountInvest[ id=" + id + " ]";
    }

    public byte[] getInvestNameBit() {
        return investNameBit;
    }

    public void setInvestNameBit(byte[] investNameBit) {
        this.investNameBit = investNameBit;
		this.investName = CodeTool.BitToString(investNameBit);
    }
    
}
